diff options
author | 2021-09-04 10:56:37 +0200 | |
---|---|---|
committer | 2021-09-04 10:56:37 +0200 | |
commit | a28b952eafc83ac6f6fc1a3d99805866bc41fde9 (patch) | |
tree | 5e8e99ef5ac2b11e8a8ab027a976caa9b1af480f /pages/api/note/[id].js | |
parent | 467233f771d745aeb9f4e69b93d2fb24a1a95d3e (diff) | |
download | my_apps-a28b952eafc83ac6f6fc1a3d99805866bc41fde9.tar.gz my_apps-a28b952eafc83ac6f6fc1a3d99805866bc41fde9.tar.bz2 my_apps-a28b952eafc83ac6f6fc1a3d99805866bc41fde9.zip |
routes refactor
Diffstat (limited to 'pages/api/note/[id].js')
-rw-r--r-- | pages/api/note/[id].js | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/pages/api/note/[id].js b/pages/api/note/[id].js deleted file mode 100644 index 1781210..0000000 --- a/pages/api/note/[id].js +++ /dev/null @@ -1,31 +0,0 @@ -import dbConnect from 'configs/dbConnect' -import withSession from 'hocs/withSession' -import Note from 'models/Note' - -export default withSession(async (req, res) => { - const {id} = req.query - await dbConnect() - - switch (req.method) { - case 'GET': - try { - const user = req.session.get('user') - - if (!user || !user?.isVerified || !id ) { - throw new Error('Something went wrong') - } - - const note = await Note.getNote(id) - - if (!note) { - throw new Error('Something went wrong') - } - - res.status(200).json(note) - } catch (error) { - console.log(error) - res.status(400).json({error: true}) - } - break - } -}) |